<%@ page contentType="text/html;charset=UTF-8" %>
<%@ include file="/WEB-INF/page/share/taglib.jsp" %>
<html>
<head>
<title>添加用户资料</title>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
<link rel="stylesheet" href="/css/vip.css" type="text/css">
<SCRIPT language="JavaScript" src="/js/FoshanRen.js"></SCRIPT>
<script type="text/javascript" src="/js/calendar.js"></script>
<SCRIPT language="JavaScript" src="/js/xmlhttp.js"></SCRIPT>
<script language="JavaScript">
function validateUsernameExsit(username){
	var usernameview = document.getElementById('name_info');	
	if(trim(username)!=""){
		usernameview.innerHTML="正在验证登录账号..."
		if(usernameview){
			send_request(function(value){usernameview.innerHTML=value},
					 '<s:url action="employee_check.html"/>?username='+ username, true);
		}
	}
	else{
		usernameview.innerHTML="登录账号不能为空";
	}
}

function validateCardnoExsit(cardno){
	var cardnoview = document.getElementById('cardno_info');	
	if(trim(cardno)!=""){
		cardnoview.innerHTML="正在身份证号..."
		if(cardnoview){
			send_request(function(value){cardnoview.innerHTML=value},
					 '<s:url action="employee_checkCardno.html"/>?cardno='+ cardno, true);
		}
	}
	else{
		cardnoview.innerHTML="身份证号不能为空";
	}
}

function validateField(fieldvalue,message,msgId){
	var msg=document.getElementById(msgId);
	if(trim(fieldvalue)==""){
		msg.innerHTML=message;
		return false;
	}else{
		msg.innerHTML="";
		return true;
	}
}

function validateImg(picture){
	if(trim(picture)!=""){
		var ext = picture.substring(picture.lastIndexOf(".")+1).toLowerCase();
		if (ext!="jpg" && ext!="gif" && ext!="bmp" && ext!="png"){
			document.getElementById("imagefile_info").innerHTML="只允许上传gif、jpg、bmp、png";
			return false; 
		}else{
			document.getElementById("imagefile_info").innerHTML="";
		}
	}
	return true
}

function checkfm(){
	var field=document.getElementById("username");
	if(!validateField(field.value,"登录账号不能为空","name_info"))return false;
	field=document.getElementById("pass");
	if(!validateField(field.value,"登录密码不能为空","pass_info"))return false;
	var pass=field.value;
	field=document.getElementById("pass2");
	if(!validateField(field.value,"确认密码不能为空","pass2_info"))return false;
	if(pass!=field.value){
		document.getElementById("pass2_info").innerHTML="登录密码和确认密码不相同";
		return false;
	}
	field=document.getElementById("realname");
	if(!validateField(field.value,"用户姓名不能为空","realname_info"))return false;
	field=document.getElementById("imgfile");
	if(!validateImg(field.value))return false;
	field=document.getElementById("cardno");
	if(!validateField(field.value,"身份证号码不能为空","cardno_info"))return false;
	field=document.getElementById("birthday");
	if(!validateField(field.value,"身份证出生日期不能为空","birthday_info"))return false;
	field=document.getElementById("address");
	if(!validateField(field.value,"身份证地址不能为空","address_info"))return false;
	return true;
}
</script>
</head>
<body bgcolor="#FFFFFF" text="#000000" leftmargin="0" topmargin="0" marginwidth="0" marginheight="0">
<s:form action="employee_add.html" method="post" enctype="multipart/form-data" onsubmit="return checkfm()">
  <table width="98%" height="35" border="0" align="center"
  	style="margin-top: 6px;margin-bottom: 10px;">
  	<tr style="background-color: #9CDCF9;"><td class="STYLE1">
  		&nbsp;&nbsp;&nbsp;&nbsp;你现在的位置是： &nbsp;用户资料管理&nbsp; &gt;&gt; &nbsp;添加用户资料</td>
  	</tr>
  	</table>
  <table width="98%" border="0" align="center">
    <tr bgcolor="f5f5f5"> 
      <td width="25%" > </td>
      <td width="75%">
        <font color="#FF0000"><s:fielderror/></font>
      </td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td width="25%" > <div align="right">登录账号：</div></td>
      <td width="75%"> 
      	<s:textfield id="username" name="username" size="32" maxlength="32" onblur="javascript:validateUsernameExsit(this.value)"/>
        <font color="#FF0000">* <span id="name_info"></span></font>
      </td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td> <div align="right">登录密码：</div></td>
      <td> <s:password id="pass" name="employee.password" size="32" maxlength="32"
      		onblur="validateField(this.value,'登录密码不能为空','pass_info')"/>
        <font color="#FF0000">* <span id="pass_info"></span></font></td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td> <div align="right">确认密码：</div></td>
      <td> <input type="password" id="pass2" size="32" maxlength="32"
      		onblur="validateField(this.value,'确认密码不能为空','pass2_info')"/>
        <font color="#FF0000">* <span id="pass2_info"></span></font></td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td> <div align="right">用户姓名：</div></td>
      <td> <s:textfield id="realname" name="employee.realname" size="10" maxlength="10"
      		onblur="validateField(this.value,'用户姓名不能为空','realname_info')"/>
        <font color="#FF0000">* <span id="realname_info"></span></font></td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td> <div align="right">性别：</div></td>
      <td> <select name="sex">
      	<option value="MAN">男</option>
      	<option value="WOMAN">女</option></select></td>
    </tr> 
    <tr bgcolor="f5f5f5"> 
      <td> <div align="right">用户类别：</div></td>
      <td> <select name="usercate">
      	<option value="STUDENT">考生</option>
      	<option value="TEACHER">教师</option></select></td>
    </tr> 
	<tr bgcolor="f5f5f5"> 
      <td> <div align="right">员工照片：</div></td>
      <td> <input type="file" id="imgfile" name="imagefile" size="50" onchange="validateImg(this.value)">
      	<font color="#FF0000"> <span id="imagefile_info"></span></font>
      </td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td> <div align="right">身份证号码：</div></td>
      <td> <s:textfield id="cardno" name="employee.idcard.cardno" size="20" maxlength="18"
      		onblur="validateCardnoExsit(this.value)"/>
        <font color="#FF0000">* <span id="cardno_info"></span></font></td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td> <div align="right">身份证出生日期：</div></td>
      <td> <s:textfield id="birthday" name="employee.idcard.birthday" size="20" maxlength="18" onfocus="calendar()"
      		onblur="validateField(this.value,'身份证出生日期不能为空','birthday_info')"/>
        <font color="#FF0000">* <span id="birthday_info"></span></font></td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td> <div align="right">身份证地址：</div></td>
      <td> <s:textfield id="address" name="employee.idcard.address" size="60" maxlength="100"
      		onblur="validateField(this.value,'身份证地址不能为空','address_info')"/>
        <font color="#FF0000">* <span id="address_info"></span></font></td>
    </tr>  
    <tr bgcolor="f5f5f5"> 
      <td> <div align="right">手机号：</div></td>
      <td><s:textfield name="employee.phone" size="20" maxlength="18"/></td>
    </tr> 
    <tr bgcolor="f5f5f5"> 
      <td> <div align="right">电子邮件：</div></td>
      <td> <s:textfield name="employee.email" size="20" maxlength="18"/></td>
    </tr> 
    <tr bgcolor="f5f5f5"> 
      <td> <div align="right">学历：</div></td>
      <td><s:textfield name="employee.degree" size="10" maxlength="5"/></td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td> <div align="right">所属组织结构：</div></td>
      <td> <c:forEach items="${departments}" var="department">
		<input type="checkbox" name="departmentids" value="${department.id}" />${department.name}　
	 </c:forEach></td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td> <div align="right">设置权限角色：</div></td>
      <td> <c:forEach items="${privilegegroups}" var="privilegegroup">
		<input type="checkbox" name="privilegegroupids" value="${privilegegroup.id}" />${privilegegroup.name}　
	 </c:forEach></td>
    </tr>
    <tr bgcolor="f5f5f5"> 
      <td width="25%" > </td> 
      <td width="75%">
      	  <s:token/><br/>
          <input type="submit" value=" 确 定 " class="frm_btn">&nbsp;&nbsp;
          <input type="button" name="Button" value=" 返 回 " class="frm_btn" onclick="javascript:history.back()">
       </td>
    </tr>
  </table>
</s:form>
</body>
</html>